package entities;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.*;

@Entity
@Table(name = "ItemsVenta")
public class ItemVenta implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	

	@EmbeddedId
	private ArticuloVenta idArticuloVenta;

	private int cantidad;

	
	public ItemVenta () {
		idArticuloVenta = new ArticuloVenta();
	}
	
	public double getSubtotal(){
		return idArticuloVenta.getArticulo().getPrecio()*cantidad;
	}
	public ArticuloVenta getId() {
		return idArticuloVenta;
	}
	public void setId(ArticuloVenta id) {
		this.idArticuloVenta = id;
	}
	

	public int getCantidad() {
		return cantidad;
	}
	public void setCantidad(int cantidad) {
		this.cantidad = cantidad;
	}
	
	public Articulo getArticulo(){
		return this.idArticuloVenta.getArticulo();
	}

	public void setArticulo( Articulo art ) {
		idArticuloVenta.setArticulo(art);
	}
	public void setVenta(Venta v){
		this.idArticuloVenta.setVenta(v);
	}

	public int getCodigoArticulo() {
		return idArticuloVenta.getArticulo().getCodigo();
	}
	
}
